import http from '@/utils/http'
interface Params {
    planId:string
}
import type {
    AxiosHeaders,
  } from 'axios'

export const download = async(url:string, params:Params) =>{
//     const result = await http.service({
//         url:url,
//         params,
//         responseType: 'blob',
//         timeout: 1000000,
//     })
//     console.log(result)
   const result:any = await http.get(url,{params, responseType: 'blob', timeout: 1000000,})
   if(!result) return
   console.log(result);
   
   let link = document.createElement('a')
      link.href = window.URL.createObjectURL(new Blob([result.data]))
      link.target = '_blank'
      let filename = result.headers['content-disposition']
      link.download = decodeURI(filename)
      document.body.appendChild(link)
      link.click()
      document.body.removeChild(link)
   
    // http({
    //   method: 'get',
    //   url: url,
    //   timeout: 1000000,
    //   params: params,
    //   responseType: 'blob'
    // }).then(response => {
    //   if (!response) {
    //     return
    //   }
    //   console.log(response,'response');
    //   let link = document.createElement('a')
    //   link.href = window.URL.createObjectURL(new Blob([response.data]))
    //   link.target = '_blank'
    //   let filename = response.headers['content-disposition']
    //   link.download = decodeURI(filename)
    //   document.body.appendChild(link)
    //   link.click()
    //   document.body.removeChild(link)
    // // eslint-disable-next-line handle-callback-err
    // }).catch((error) => {
  
    // })
  }